import { platformOrderListColumns } from './platformOrderList.config.js'
import { shopPurchaseinfoList, addObj, purchaseinfo, delObj } from '@/api/shop/procurement.js'
import search from './../search/search.js';
export default {
    name: "platformOrderList",
    mixins: [search],
    data() {
        return {
            platformOrderListColumns,
            loading: false,
            loadData: [],
            page: {
                current: 1,
                total: 0,
                size: 10
            },
            btn: [
                {
                    title: "新增采购单",
                    isShow: true
                },
            ],
            searchForm:{}
        }
    },
    methods: {
        getList(searchForm, page) {
            if (searchForm) {
                console.log(searchForm)
                this.searchForm = searchForm
            }
            if (page) {
                this.page.current = page
            }
            shopPurchaseinfoList(Object.assign({deptId: this.$store.getters.userInfo.sysUser.deptId, tenantId: this.$store.getters.userInfo.sysUser.tenantId}, this.searchForm, this.page,)).then((val) => {
                let data = val.data
                this.page = {
                    current: data.current,
                    total: data.total,
                    size: data.size,
                }
                data.records.forEach(ele => {
                    if (ele.status == '00') {
                        ele.statusH = "待配单"
                    }
                    if (ele.status == '01') {
                        ele.statusH = "待配送"
                    }
                    if (ele.status == '02') {
                        ele.statusH = "已完成"
                    }
                    if (ele.status == '03') {
                        ele.statusH = "已取消"
                    }
                })
                this.loadData = data.records
                console.log(666, val)

            })
        },
        onShowSizeChange(current, size) {
            console.log(current, size)
            this.page.current = current
            this.page.size = size
            this.getList()
        },

        handler(index) {
            if (index == 0) {
                this.platformOrderList()
            }
        },
        // 新增采购单
        platformOrderList() {
            this.$router.push({ path: "/shop/procurement/addOrder" })
        },
        edit(row) {
            this.$router.push({
                path: "/shop/procurement/addOrder",
                query: {
                    id: row.purchaseInfoId
                }
            })
        },
        detail(row) {
            this.$router.push({
                path: "/shop/procurement/orderDetails",
                query: {
                    purchaseInfoId: row.purchaseInfoId,
                    status:row.status
                }
            })
        },
        dropOrder(e) {
            console.log(e)
            delObj(e.purchaseInfoId).then(result => {
                this.getList()
            })
        }

    }
}